﻿using Glue;
using GlueTests.Builders;
using Xunit;

namespace GlueTests.RelationContainerTests
{
    public class When_removing_a_relation
    {
        public class GuiPerson { public int Id { get; set; } }
        public class DomainPerson { public int Id { get; set; } }

        private readonly Mapping<DomainPerson, GuiPerson> mapping;

        public When_removing_a_relation()
        {
            mapping = new Mapping<DomainPerson, GuiPerson>();
            mapping.Relate(domain => domain.Id, gui => gui.Id);
            mapping.Relations.Remove(domain => domain.Id, gui => gui.Id);
        }

        [Fact]
        public void No_relation_should_exist()
        {
            Assert.Equal(0, mapping.Relations.Count);
        }

        [Fact]
        public void Should_not_have_any_related_properties_towards_left()
        {
            Assert.False(mapping.Relations.IsRelatedTowardsOnLeftSide(new PropertyBuilder(typeof(DomainPerson),"Id").Build()));
        }

        [Fact]
        public void Should_not_have_any_related_properties_towards_right()
        {
            Assert.False(mapping.Relations.IsRelatedTowardsOnRightSide(new PropertyBuilder(typeof(DomainPerson),"Id").Build()));
        }
    }
}
